package com.npf.imgserver.controller;

import com.npf.imgserver.common.base.ResultBase;
import com.npf.imgserver.common.enums.ResultCodeEnum;
import com.npf.imgserver.entity.Customer;
import com.npf.imgserver.entity.ImgInfo;
import com.npf.imgserver.service.api.ImgInfoService;
import com.npf.imgserver.utils.ExportExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.juli.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author nipengfei
 * @since 2018-09-22
 */
@Api(value = "/imginfo", tags = "图片信息模块")
@RestController
@RequestMapping("/imginfo")
public class ImgInfoController {

    public static final Logger logger = LoggerFactory.getLogger(ImgInfoController.class);
    @Autowired
    private ImgInfoService imgInfoService;

    /**
     * 图片信息Excel导出
     *
     * @param response
     */
    @GetMapping("/exportImgInfo")
    @ApiOperation(value = "图片信息Excel导出", notes = "图片信息Excel导出")
    public void exportImgInfo(HttpServletResponse response) {
        try {
            //表格导出 需注意sheet最大行数 65536
            List<ImgInfo> imgInfoList = imgInfoService.queryImgInfo();
            //导出操作
            ExportExcelUtil.exportExcel(imgInfoList, "图片信息列表", "图片信息", ImgInfo.class, "图片信息列表.xls", response);
        } catch (Exception e) {
            logger.error("图片信息Excel导出失败", e);
        }
    }
}
